<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>360商城</title>
		<link rel="stylesheet" type="text/css" href="./Public/Home/css/common.css"/>
		<link rel="stylesheet" type="text/css" href="./Public/Home/css/login.css"/>
		<link rel="stylesheet" type="text/css" href="./Public/Home/css/order.css"/>
		<link rel="stylesheet" type="text/css" href="./Public/Home/css/index.css"/>
		<script src="./Public/Home/js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="./Public/Home/js/common.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
{{include file="VIEW_PATH/Common/header.php"}}
		<article>
		<div id="gcat_order">
			<div class="gcart">
				<div class="Hd">
					我的购物车
				</div>
				<?php if(!empty($_SESSION['cart']['goods'])&&isset($_SESSION['uid'])){ ?>
				<div class="sp">
					<div class="cart_list">
						<div class="hd">
                            <div class="col1">商品信息</div>
							<div class="col2">单价</div>
							<div class="col3">数量</div>
							<div class="col4">小计</div>
							<div class="col5">操作</div>
						</div>
				<script type="text/javascript">
					$(function(){
						$(".del_good").click(function(){
							if(confirm("确认删除吗？")){
						var gsid= $(this).parents('.bd').find(".goodscount").attr("gsid");
						
						
								var _this = $(this);
								$.ajax({
									type:"post",
									url:"{{U('delCart')}}",
									data:{gsid:gsid},
									dataType:'json',
								success:function(data){									
                                     
                                      if(data){
									 _this.parents(".bd").remove();
									$(".gAmount span").html(data);    
									return; 	
                                      }
               
                                       window.location.href=window.location.href;

									
								}	
							  });
							}
						})
						$(".num_plus").click(function(){
							var num = $(this).prev(".put_num").val();
							var _this = $(this);
						    var gsid= $(this).prev(".put_num").attr("gsid");
							$.ajax({
								type:"post",
								url:"{{U('updateCart')}}",
								data:{num:num,gsid:gsid},
								dataType:'json',
								success:function(data){
							_this.parents(".bd").find(".r4 span").html(data[gsid].total);

                               $(".gAmount span").html(data[gsid].sum);
                              }
							});
						})
						//点击减号
							$(".num_minus").click(function(){
							num = $(this).next(".put_num").val();
						    gsid= $(this).next(".put_num").attr("gsid");
						    var _this = $(this);
							$.ajax({
								type:"post",
								url:"{{U('updateCart')}}",
								data:{num:num,gsid:gsid},
								dataType:'json',
								success:function(data){
									if(data){
									_this.parents(".bd").find(".r4 span").html(data[gsid].total);
									$(".gAmount span").html(data[gsid].sum);
									}
								}
							});
						})
					})
					
				</script>
				
						{{foreach from="$data" key="$k" value="$v"}}
					    <div class="bd">
					    	<div class="warp_row">
					    		<div class="r1">
					    			<img src="{{$v['id']['g_pic']}}" alt="" />
					    			<span class="item_name"> {{$v['name']}}</span>
					    		</div>
					    		<div class="r2">
					    			<span >{{$v['price']}}</span>元
					    		</div>
					    		<div class="r3 pro_num">
					    			<a href="javascript:void(0);" class="num_minus"></a>
					    			<input type="text"  class="goodscount put_num" gsid = "{{$k}}" value="{{$v['num']}}"/>
					    			<a href="javascript:void(0);"  class="num_plus"></a>
					    		</div>
					    		<div class="r4">
					    			<span >{{$v['price']*$v['num']}}</span>元
					    		</div>
					    		<div class="r5">
					    			<a href="javascript:void(0);" class="del_good">删除</a>
					    		</div>
					    		
					    	</div>
					    </div>
					    
					    {{endforeach}}
					    
					    
					    
					    
					     <!--总价钱-->
					     <div class="gAmount">
					        	商品总价:<span>{{$data[$k]['sum']}}</span>.00元
					        </div>
					     <!--去结算-->
					     <div class="btn">
					     	<a href="index.html" class="b1">继续购物</a>
					     	<a href="gotoorder.html"  class="b1  b2">去结算</a>
					     </div>
					     <?php }else{ ?>
					     	<div class="sp">
					     		<div class="emptyCart">
					     			<a href="cate_0.html" class="goShopping" title="马上去购物"></a>
					     		</div>
					     	</div>
					     	<?php } ?>
					</div>
				</div>
			</div>
		</div>
		</article>
{{include file="VIEW_PATH/Common/footer.php"}}
<!--登录页面-->
{{include file="VIEW_PATH/Common/login.php"}}
<!--注册页面-->
{{include file="VIEW_PATH/Common/register.php"}}
		<!--右侧固定定位-->
{{include file="VIEW_PATH/Common/guright.php"}}
	</body>
</html>
